/*
 * 
 * 
 * @author: Oren Zamir
 */
package org.valire.usermanagement.services;

import java.util.List;
import java.util.Set;

import org.valire.usermanagement.NodeAccessPermissionManagementFacade;
import org.valire.usermanagement.beans.NodeAccessPermission;
import org.valire.usermanagement.beans.Role;
import org.valire.usermanagement.beans.User;

/**
 * The Interface AccessControlMethodService.
 */
public interface NodeAccessPermissionService {

	/**
	 * Removes the all na ps for roles.
	 *
	 */
	public void refreshCache();

	/**
	 * Creates the acm.
	 * 
	 * @param nap
	 *            the nap
	 * @return the role
	 */
	public NodeAccessPermission createNAP(NodeAccessPermission nap);

	/**
	 * Removes the acm.
	 * 
	 * @param nap
	 *            the nap
	 */
	public void removeNAP(NodeAccessPermission nap);

	/**
	 * Gets the all roles.
	 * 
	 * @return the all roles
	 */
	public List<NodeAccessPermission> getAllNAPs();

	/**
	 * Gets the method roles.
	 *
	 * @param role the role
	 * @return the method roles
	 */
	Set<NodeAccessPermission> getNAPsForRole(Role role);

	/**
	 * Gets the nA ps for roles.
	 *
	 * @param roles the roles
	 * @return the nA ps for roles
	 */
	Set<NodeAccessPermission> getNAPsForRoles(Set<Role> roles);

	/**
	 * Gets the nA ps for users.
	 *
	 * @param user the user
	 * @return the nA ps for users
	 */
	Set<NodeAccessPermission> getNAPsForUser(User user);

	/**
	 * Gets the nA ps for users.
	 *
	 * @param allUsers the all users
	 * @return the nA ps for users
	 */
	Set<NodeAccessPermission> getNAPsForUsers(Set<User> allUsers);

	/**
	 * Check method access for role.
	 * 
	 * @param role
	 *            the role
	 * @param method
	 *            the method
	 * @param validationInterface
	 *            the validation interface
	 * @return true, if successful
	 */
	boolean hasPermissionForRole(Role role, String method,
			NodeAccessPermissionManagementFacade.NAPValidationInterface validationInterface);

	/**
	 * Checks for permission.
	 * 
	 * @param role
	 *            the role
	 * @param method
	 *            the method
	 * @param validationInterface
	 *            the validation interface
	 * @return true, if successful
	 */
	boolean hasPermissionForRoles(Set<Role> role, String method,
			NodeAccessPermissionManagementFacade.NAPValidationInterface validationInterface);

	/**
	 * Checks for permission.
	 * 
	 * @param user
	 *            the user
	 * @param method
	 *            the method
	 * @param validationInterface
	 *            the validation interface
	 * @return true, if successful
	 */
	boolean hasPermissionForUser(User user, String method,
			NodeAccessPermissionManagementFacade.NAPValidationInterface validationInterface);

	/**
	 * Checks for permission.
	 * 
	 * @param users
	 *            the users
	 * @param method
	 *            the method
	 * @param validationInterface
	 *            the validation interface
	 * @return true, if successful
	 */
	boolean hasPermissionForUsers(Set<User> users, String method,
			NodeAccessPermissionManagementFacade.NAPValidationInterface validationInterface);

	/**
	 * Update mac.
	 * 
	 * @param nap
	 *            the nap
	 */
	void updateNAPs(NodeAccessPermission nap);

	/**
	 * Removes the all na ps for users.
	 * 
	 * @param users
	 *            the users
	 */
	void removeAllNAPsForUsers(Set<User> users);

	/**
	 * Removes the all na ps for roles.
	 * 
	 * @param roles
	 *            the roles
	 */
	void removeAllNAPsForRoles(Set<Role> roles);


}
